Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class com.pacist.diamonds.LinearController

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--com.pacist.diamonds.DiamondCanvas
                    |
                    +--com.pacist.diamonds.Controller
                          |
                          +--com.pacist.diamonds.LinearController
Subclasses:
ProgressBar, Slider

public abstract class LinearController
extends Controller
Implements the base functionality for linear controllers (ProgressBars, Sliders, etc.)

See Also:
Serialized Form

Field Summary
boolean hasPeer
          A boolean variable which records whether a peer has been assigned to this component.
static int HORIZONTAL
          Specifies horizontal orientation for a Slider
int orientation
          Holds the current orientation of the controller.
int thumbSize
          The size of the button you drag to change the value.
java.awt.Rectangle trackRect
          This holds the dimensions of the rectangle which is the background of the controller.
java.awt.Rectangle valueRect
          This holds the dimensions of the rectangle which shows the current value of the controller.
static int VERTICAL
          Specifies vertical orientation for a Slider
 
Fields inherited from class com.pacist.diamonds.Controller
canMeasure, listeners, maxValue, minValue, postOnMouseDown, postWhileDragging, showValue, value
 
Fields inherited from class com.pacist.diamonds.DiamondCanvas
tipText
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
LinearController(int min, int max, int initial, int o)
          Creates and initializes a LinearController object with the specified minimum, maximum, initial, and orientation values.
LinearController()
          Creates and initializes a LinearController object with a minimum value of 0, a maximum value of 100, an initial value of 0, and a horizontal orientation.
 
Method Summary
void addNotify()
          This method is called when the Controller has been given it's peer and has been realised.
void doValueAtEndLayout()
          Lays out the controller with the value at the end.
java.awt.Dimension getMinimumSize()
          Returns the minimum size of the Controller.
int getOrientation()
          Gets the current orientation of the controller
java.awt.Dimension getPreferredSize()
          Returns the preferred size of the Controller.
java.awt.Rectangle getThumbRect()
          Returns the dimensions of the Thumb rectangle.
java.awt.Rectangle getTrackRect()
          Returns the dimensions of the Track rectangle. layoutAreas() is called beforehand to use the latest values.
java.awt.Color getValueColor()
          Returns the color of the Value.
java.awt.Point getValuePos()
          Returns an x,y coordinate for the position of the numeric value displayed.
java.awt.Rectangle getValueRect()
          Returns the dimensions of the Value rectangle.
void layoutAreas()
          Calls the necessary methods to lay out the controller.
java.awt.Dimension minimumSize()
          Deprecated. Returns the minimum size of the Controller.
void paint(java.awt.Graphics g)
          This method is called to repaint the controller.
void paintThumb(java.awt.Graphics g)
          Draws the thumb of the slider.
void paintTrack(java.awt.Graphics g)
          Draws the track of the slider.
void paintValue(java.awt.Graphics g)
          Draws the value of the slider.
void paintValueOneColor(java.awt.Graphics g)
          Draws the value of the slider in one color (the normal case when the value is positioned outside the track)
int pointToValue(int x, int y)
          Converts given X and Y coordinates to a value.
java.awt.Dimension preferredSize()
          Deprecated. Returns the preferred size of the Controller.
void repaintPostValueChange(java.awt.Rectangle oldThumb, java.awt.Rectangle newThumb)
          This method is called whenever the value of the Controller changes.
void setBounds(int x, int y, int width, int height)
          Moves and resizes the controller.
void setOrientation(int o)
          Sets the orientation of the controller.
void setValue(int v)
          Sets the value of the slider, causing it to be redrawn.
int valueToX(int v, java.awt.Rectangle r)
          Converts a given value and Rectangle to an X coordinate.
 
Methods inherited from class com.pacist.diamonds.Controller
addControllerListener, getMaxValue, getMinValue, getPostOnMouseDown, getShowValue, getValue, getValueString, isMaxAtBottom, mouseDragged, mousePressed, mouseReleased, notifyValueChange, pinValue, pointToValue, processMouseEvent, processMouseMotionEvent, removeControllerListener, setMaxAtBottom, setMaxValue, setMinValue, setPostOnMouseDown, setShowValue, setValue
 
Methods inherited from class com.pacist.diamonds.DiamondCanvas
getTipText, mouseEnter, mouseExit, processMouseEvent, setTipText
 
Methods inherited from class java.awt.Canvas
addNotify, paint
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paint, paramString, postEvent, preferredSize, prepareImage, prepareImage, printAll, print, processComponentEvent, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Field Detail

HORIZONTAL

public static final int HORIZONTAL
Specifies horizontal orientation for a Slider

VERTICAL

public static final int VERTICAL
Specifies vertical orientation for a Slider

thumbSize

protected int thumbSize
The size of the button you drag to change the value.

orientation

protected int orientation
Holds the current orientation of the controller.
See Also:
HORIZONTAL, VERTICAL

valueRect

protected java.awt.Rectangle valueRect
This holds the dimensions of the rectangle which shows the current value of the controller.

trackRect

protected java.awt.Rectangle trackRect
This holds the dimensions of the rectangle which is the background of the controller.

hasPeer

protected boolean hasPeer
A boolean variable which records whether a peer has been assigned to this component.
Constructor Detail

LinearController

public LinearController(int min,
                        int max,
                        int initial,
                        int o)
Creates and initializes a LinearController object with the specified minimum, maximum, initial, and orientation values.
Parameters:
min - the minimum value for the controller.
max - the maximum value for the controller.
initial - the initial value for the controller.
o - the orientation of the controller.
See Also:
#HORIZONTAL, #VERTICAL

LinearController

public LinearController()
Creates and initializes a LinearController object with a minimum value of 0, a maximum value of 100, an initial value of 0, and a horizontal orientation.
Method Detail

repaintPostValueChange

public abstract void repaintPostValueChange(java.awt.Rectangle oldThumb,
                                            java.awt.Rectangle newThumb)
This method is called whenever the value of the Controller changes.
Parameters:
oldThumb - thumb coordinates before change
newThumb - thumb coordinates after change

setValue

public void setValue(int v)
Sets the value of the slider, causing it to be redrawn. The value will be pinned to be between the minimum and maximum values.
Parameters:
v - the new value.
Overrides:
setValue in class Controller

setOrientation

public void setOrientation(int o)
Sets the orientation of the controller.
Parameters:
o - the orientation.
See Also:
HORIZONTAL

getOrientation

public int getOrientation()
Gets the current orientation of the controller
Returns:
int - the orientation of the controller.
See Also:
HORIZONTAL

getPreferredSize

public java.awt.Dimension getPreferredSize()
Returns the preferred size of the Controller.
Returns:
Dimension - the size of the controller.
Overrides:
getPreferredSize in class java.awt.Component

preferredSize

public java.awt.Dimension preferredSize()
Deprecated. as of JDK1.1.
Returns the preferred size of the Controller.
Overrides:
preferredSize in class java.awt.Component
See Also:
getPreferredSize

getMinimumSize

public java.awt.Dimension getMinimumSize()
Returns the minimum size of the Controller.
Returns:
Dimension - the minimum size of the controller.
Overrides:
getMinimumSize in class java.awt.Component

minimumSize

public java.awt.Dimension minimumSize()
Deprecated. as of JDK1.1.
Returns the minimum size of the Controller.
Overrides:
minimumSize in class java.awt.Component
See Also:
getMinimumSize

paintTrack

protected abstract void paintTrack(java.awt.Graphics g)
Draws the track of the slider. Override to provide a different look to the slider.
Parameters:
g - the graphics context.

paintThumb

protected abstract void paintThumb(java.awt.Graphics g)
Draws the thumb of the slider. Override to provide a different look to the slider.
Parameters:
g - the graphics context.

getValueColor

protected java.awt.Color getValueColor()
Returns the color of the Value.

getValuePos

protected java.awt.Point getValuePos()
Returns an x,y coordinate for the position of the numeric value displayed.

paintValue

protected void paintValue(java.awt.Graphics g)
Draws the value of the slider. Override to provide a different look to the slider.
Parameters:
g - the graphics context.

paintValueOneColor

protected void paintValueOneColor(java.awt.Graphics g)
Draws the value of the slider in one color (the normal case when the value is positioned outside the track)

layoutAreas

protected void layoutAreas()
Calls the necessary methods to lay out the controller. Default is doValueAtEndLayout().
See Also:
doValueAtEndLayout

doValueAtEndLayout

protected void doValueAtEndLayout()
Lays out the controller with the value at the end.

getTrackRect

protected java.awt.Rectangle getTrackRect()
Returns the dimensions of the Track rectangle. layoutAreas() is called beforehand to use the latest values.
Returns:
Rectangle - the dimensions of the track rectangle.

getThumbRect

protected abstract java.awt.Rectangle getThumbRect()
Returns the dimensions of the Thumb rectangle.

getValueRect

protected java.awt.Rectangle getValueRect()
Returns the dimensions of the Value rectangle.

valueToX

protected int valueToX(int v,
                       java.awt.Rectangle r)
Converts a given value and Rectangle to an X coordinate.
Parameters:
v - given value.
r - the rectangle the value resides in.
Returns:
int - the X coordinate which lies inside the given rectangle.

pointToValue

protected int pointToValue(int x,
                           int y)
Converts given X and Y coordinates to a value.
Parameters:
x - the X coordinate
y - the Y coordinate
Returns:
int - a value derived from the above coordinates, the Track rectangle, and the minimum and maximum values.
Overrides:
pointToValue in class Controller

paint

public void paint(java.awt.Graphics g)
This method is called to repaint the controller.
Parameters:
g - the graphics context.
Overrides:
paint in class java.awt.Canvas

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Moves and resizes the controller. The new location of the top-left corner is specified by x and y, and the new size is specified by width and height.
Parameters:
x - The new x-coordinate of the controller.
y - The new y-coordinate of the controller.
width - The new width of the controller.
height - The new height of the controller.
Overrides:
setBounds in class java.awt.Component
See Also:
getBounds, setLocation(int, int), setLocation(java.awt.Point), setSize(int, int), setSize(java.awt.Dimension)

addNotify

public void addNotify()
This method is called when the Controller has been given it's peer and has been realised.
Overrides:
addNotify in class java.awt.Canvas

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD